package com.ailiwu.www.ailiwu.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.ailiwu.www.ailiwu.Fragment.HotFragment;
import com.ailiwu.www.ailiwu.R;
import com.ailiwu.www.ailiwu.base.BaseActivity;

/**
 * Created by zzw on 2015/12/7.
 */
public class ClassifyGiftActivity extends BaseActivity {
    private FrameLayout frameLayout;
    private Toolbar toolbar;
    private FragmentManager fmanager;
    private TextView toolbar_title;

    @Override
    protected void loadXml() {
        setContentView(R.layout.activity_classifygift);

    }

    @Override
    protected void getIntentData(Bundle savedInstanceState) {

    }

    @Override
    protected void initView() {

        toolbar_title = (TextView) findViewById(R.id.toolbar_title);
        toolbar = (Toolbar) findViewById(R.id.toolbar_gift_recyc);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        frameLayout = (FrameLayout) findViewById(R.id.fl_gift_content);
    }

    @Override
    protected void setListener() {

    }

    @Override
    protected void initData() {
        Intent intent = getIntent();
        String url = intent.getStringExtra("urlID");
        String title = intent.getStringExtra("name");


        fmanager = getSupportFragmentManager();
        toolbar_title.setText(title);
        FragmentTransaction ft = fmanager.beginTransaction();
        Fragment fragment = new HotFragment().newInstance(url);
        ft.replace(R.id.fl_gift_content, fragment);
        ft.commit();

    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                break;
            default:
                break;
        }
        return super.onOptionsItemSelected(item);
    }
}
